package 双指针;

/**
 * @author zhengTao
 * @version 1.0
 * @description: 移动零  也是双指针
 * @date 2022/10/14 14:56
 */
public class Demo283 {
    public static void main(String[] args) {
        moveZeroes(new int[]{0,1,0,3,12});
    }

    public static void moveZeroes(int[] nums) {
        if(nums.length<2){
            return;
        }
        int slow=0;
        for (int i = 0; i < nums.length; i++) {
            if(nums[i]!=0){
                nums[slow++]=nums[i];
            }
        }
        for (int i = slow; i <nums.length ; i++) {
            nums[i]=0;
        }
    }
}
